package com.easyadmin.modules.stock.controller;

import com.easyadmin.common.web.base.BaseController;
import com.easyadmin.common.web.domain.request.PageDomain;
import com.easyadmin.common.web.domain.response.module.ResultTable;
import com.easyadmin.modules.stock.domain.SysFuturesPriceReport;
import com.easyadmin.modules.stock.domain.SysInvestModelEntity;
import com.easyadmin.modules.stock.domain.SysReportVo;
import com.easyadmin.modules.stock.service.SysFuturesPriceReportService;
import com.easyadmin.modules.stock.vo.SyFuturesDayPriceVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/stock/report")
public class SysFuturesPriceReportController extends BaseController {

    @Autowired
    private SysFuturesPriceReportService sysFuturesPriceReportService;

    /**
     * Describe: 基础路径
     */
    private static String MODULE_PATH = "stock/report/";

    /**
     * Describe: 获取列表视图
     * Param ModelAndView
     * Return 列表视图
     */
    @GetMapping("main")
    @ApiOperation(value = "分页列表视图")
    @PreAuthorize("hasPermission('/stock/report/main','stock:report:main')")
    public ModelAndView main() {
        return jumpPage(MODULE_PATH + "main");
    }



    /**
     * 分页查询
     */
    @ResponseBody
    @GetMapping("/list")
    @PreAuthorize("hasPermission('/stock/report/list','stock:report:list')")
    public ResultTable list(@ModelAttribute SysFuturesPriceReport sysInvestModelEntity, PageDomain pageDomain) {
        PageInfo<SysFuturesPriceReport> pageInfo = sysFuturesPriceReportService.queryPage(sysInvestModelEntity, pageDomain);
        return pageTable(pageInfo.getList(), pageInfo.getTotal());
    }



    /**
     * Describe: 获取列表视图
     * Param ModelAndView
     * Return 列表视图
     */
    @GetMapping("nmain")
    @ApiOperation(value = "分页列表视图")
    @PreAuthorize("hasPermission('/stock/report/nmain','stock:report:nmain')")
    public ModelAndView nmain() {
        return jumpPage(MODULE_PATH + "nmain");
    }

    /**
     * 分页查询
     */
    @ResponseBody
    @GetMapping("/nlist")
    @PreAuthorize("hasPermission('/stock/report/nlist','stock:report:nlist')")
    public ResultTable nlist(@ModelAttribute SysReportVo sysReportVo, PageDomain pageDomain) {
        PageInfo<SyFuturesDayPriceVo> pageInfo = sysFuturesPriceReportService.nqueryPage(sysReportVo, pageDomain);
        return pageTable(pageInfo.getList(), pageInfo.getTotal());
    }



}
